package com.ssy.lingxi.order.controller.mobile;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderAgreeVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderIdVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderReasonVO;
import com.ssy.lingxi.order.model.vo.basic.response.PayResultDetailVO;
import com.ssy.lingxi.order.model.vo.buyer.request.BuyerOrderPayVO;
import com.ssy.lingxi.order.model.vo.buyer.request.BuyerPayResultVO;
import com.ssy.lingxi.order.model.vo.buyer.request.BuyerReceiveVO;
import com.ssy.lingxi.order.model.vo.buyer.response.BuyerPayResultDetailVO;
import com.ssy.lingxi.order.model.vo.mobile.request.MobileManagePageVO;
import com.ssy.lingxi.order.model.vo.mobile.request.MobileOrderDeliveryTimeUpdateVO;
import com.ssy.lingxi.order.model.vo.mobile.request.MobilePageVO;
import com.ssy.lingxi.order.model.vo.mobile.response.*;
import com.ssy.lingxi.order.service.mobile.IMobileBuyerOrderService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu App - 商品订单相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-09-22
 */
@RestController
@RequestMapping("/order/mobile/buyer")
public class MobileBuyerOrderController {
    @Resource
    private IMobileBuyerOrderService mobileBuyerOrderService;

    /**
     * 调整订单送货时间
     * @param headers  Http头部信息
     * @param updateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/update/delivery/time", method = RequestMethod.POST)
    public Wrapper<Void> updateDeliveryTime(@RequestHeader HttpHeaders headers, @RequestBody @Valid MobileOrderDeliveryTimeUpdateVO updateVO) {
        return mobileBuyerOrderService.updateDeliveryTime(headers, updateVO);
    }

    /**
     * 全部订单 - 获取订单内部、外部状态列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/page/items", method = RequestMethod.GET)
    public Wrapper<MobilePageItemVO> getPageItems(@RequestHeader HttpHeaders headers) {
        return mobileBuyerOrderService.getPageItems(headers);
    }

    /**
     * 全部订单 - 分页查询订单
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileOrderManageQueryVO>> pageOrders(@RequestHeader HttpHeaders headers, @Valid MobileManagePageVO pageVO) {
        return mobileBuyerOrderService.pageOrders(headers, pageVO);
    }

    /**
     * 订单退款
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 退款结果
     */
    @RequestMapping(value = "/refund", method = RequestMethod.POST)
    public Wrapper<Void> orderRefund(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderIdVO idVO) {
        return mobileBuyerOrderService.orderRefund(headers, idVO);
    }

    /**
     * 取消订单
     * @param headers Http头部信息
     * @param reasonVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/cancel", method = RequestMethod.POST)
    public Wrapper<Void> cancelOrder(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderReasonVO reasonVO) {
        return mobileBuyerOrderService.cancelOrder(headers, reasonVO);
    }

    /**
     * 全部订单 - 分页查询订单 - 订单删除
     * @param headers Http头部信息
     * @param idVO    接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/page/delete", method = RequestMethod.POST)
    public Wrapper<Void> pageOrderDelete(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderIdVO idVO) {
        return mobileBuyerOrderService.pageOrderDelete(headers, idVO);
    }

    /**
     * “待审核订单（一级）” - 分页查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/grade/one/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileOrderQueryVO>> pageToValidateGradeOneOrders(@RequestHeader HttpHeaders headers, @Valid MobilePageVO pageVO) {
        return mobileBuyerOrderService.pageToValidateGradeOneOrders(headers, pageVO);
    }

    /**
     * “待审核订单（一级）” - 审核
     * @param headers Http头部信息
     * @param agreeVO 接口参数
     * @return 审核结果
     */
    @RequestMapping(value = "/validate/grade/one", method = RequestMethod.POST)
    public Wrapper<Void> validateOrderGradeOne(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderAgreeVO agreeVO) {
        return mobileBuyerOrderService.validateOrderGradeOne(headers, agreeVO);
    }

    /**
     * “待审核订单（二级）” - 分页查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/grade/two/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileOrderQueryVO>> pageToValidateGradeTwoOrders(@RequestHeader HttpHeaders headers, @Valid MobilePageVO pageVO) {
        return mobileBuyerOrderService.pageToValidateGradeTwoOrders(headers, pageVO);
    }

    /**
     * “待审核订单（二级）” - 审核
     * @param headers Http头部信息
     * @param agreeVO 接口参数
     * @return 审核结果
     */
    @RequestMapping(value = "/validate/grade/two", method = RequestMethod.POST)
    public Wrapper<Void> validateOrderGradeTwo(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderAgreeVO agreeVO) {
        return mobileBuyerOrderService.validateOrderGradeTwo(headers, agreeVO);
    }

    /**
     * “待提交订单” - 分页查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/submit/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileToSubmitOrderQueryVO>> pageToSubmitOrders(@RequestHeader HttpHeaders headers, @Valid MobilePageVO pageVO) {
        return mobileBuyerOrderService.pageToSubmitOrders(headers, pageVO);
    }

    /**
     * “待提交订单” - 提交
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 审核结果
     */
    @RequestMapping(value = "/validate/submit", method = RequestMethod.POST)
    public Wrapper<Void> submitValidateOrder(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderIdVO idVO) {
        return mobileBuyerOrderService.submitValidateOrder(headers, idVO);
    }

    /**
     * “待支付订单” - 分页查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/pay/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileOrderQueryVO>> pageToPayOrders(@RequestHeader HttpHeaders headers, @Valid MobilePageVO pageVO) {
        return mobileBuyerOrderService.pageToPayOrders(headers, pageVO);
    }

    /**
     * “待支付订单” - 查询支付方式与支付渠道列表
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/pay/type", method = RequestMethod.GET)
    public Wrapper<List<MobilePayTypeDetailVO>> getToPayOrderPayTypes(@RequestHeader HttpHeaders headers, @Valid OrderIdVO idVO) {
        return mobileBuyerOrderService.getToPayOrderPayTypes(headers, idVO);
    }

    /**
     * “待支付订单” - 订单支付
     * @param headers HttpHeader信息
     * @param payVO 接口参数
     * @return 支付链接（在线支付）
     */
    @RequestMapping(value = "/validate/pay", method = RequestMethod.POST)
    public Wrapper<PayResultDetailVO> orderPay(@RequestHeader HttpHeaders headers, @RequestBody @Valid BuyerOrderPayVO payVO) {
        return mobileBuyerOrderService.orderPay(headers, payVO);
    }

    /**
     * “待支付订单” - 查询支付结果
     * @param headers HttpHeader信息
     * @param resultVO 接口参数
     * @return 支付结果
     */
    @RequestMapping(value = "/validate/pay/result", method = RequestMethod.GET)
    public Wrapper<BuyerPayResultDetailVO> findPayResult(@RequestHeader HttpHeaders headers, @Valid BuyerPayResultVO resultVO) {
        return mobileBuyerOrderService.findPayResult(headers, resultVO);
    }

    /**
     * “待发货订单” - 查询订单列表
     * @param headers HttpHeader信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/delivery/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileToDeliveryOrderQueryVO>> pageToDeliveryOrders(@RequestHeader HttpHeaders headers, @Valid MobilePageVO pageVO) {
        return mobileBuyerOrderService.pageToDeliveryOrders(headers, pageVO);
    }

    /**
     * “待确认收货订单” -查询订单列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/receive/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileOrderQueryVO>> pageToReceiveOrders(@RequestHeader HttpHeaders headers, @Valid MobilePageVO pageVO) {
        return mobileBuyerOrderService.pageToReceiveOrders(headers, pageVO);
    }

    /**
     * “待确认收货订单” - 确认收货
     * @param headers Http头部信息
     * @param receiveVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/validate/receive/confirm", method = RequestMethod.POST)
    public Wrapper<Void> receiveOrder(@RequestHeader HttpHeaders headers, @RequestBody @Valid BuyerReceiveVO receiveVO) {
        return mobileBuyerOrderService.receiveOrder(headers, receiveVO);
    }

    /**
     * 采购订单详情
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<MobileOrderDetailVO> findOrderDetail(@RequestHeader HttpHeaders headers, @Valid OrderIdVO idVO) {
        return mobileBuyerOrderService.findOrderDetail(headers, idVO);
    }
}
